create table PriceItem
(
	 [PriceItemId] int identity(1, 1) primary key
	,[PriceItemName] nvarchar(128)
	,[ScheduleId] int
	,[PriceId] int
	,[Quantity] int
	,[TotalPrice] decimal
	,[PriceItemType] int
	,[CreatedBy] int
	,[CreatedDate] datetime
	,[UpdatedBy] int
	,[UpdatedDate] datetime
	,[Status] int
)
go

CREATE PROCEDURE PriceItemGet
	@PriceItemId int
AS
SELECT *
FROM [PriceItem]
WHERE [PriceItem].[PriceItemId] = @PriceItemId
GO

CREATE PROCEDURE PriceItemList
AS
SELECT *
FROM [PriceItem]
ORDER BY PriceItemId DESC
GO

CREATE PROCEDURE PriceItemInsert
	@PriceItemName nvarchar(128)
	,@ScheduleId int
	,@PriceId int
	,@Quantity int
	,@TotalPrice decimal(18, 0)
	,@PriceItemType int
	,@CreatedBy int
	,@CreatedDate datetime
	,@UpdatedBy int
	,@UpdatedDate datetime
	,@Status int
AS

INSERT INTO PriceItem (
	 [PriceItemName]
	,[ScheduleId]
	,[PriceId]
	,[Quantity]
	,[TotalPrice]
	,[PriceItemType]
	,[CreatedBy]
	,[CreatedDate]
	,[UpdatedBy]
	,[UpdatedDate]
	,[Status]
	
) VALUES (
	 @PriceItemName
	,@ScheduleId
	,@PriceId
	,@Quantity
	,@TotalPrice
	,@PriceItemType
	,@CreatedBy
	,@CreatedDate
	,@UpdatedBy
	,@UpdatedDate
	,@Status
	
)

select SCOPE_IDENTITY()
GO

CREATE PROCEDURE PriceItemUpdate
	@PriceItemId int, 
	@PriceItemName nvarchar(128), 
	@ScheduleId int, 
	@PriceId int, 
	@Quantity int, 
	@TotalPrice decimal(18, 0), 
	@PriceItemType int, 
	@CreatedBy int, 
	@CreatedDate datetime, 
	@UpdatedBy int, 
	@UpdatedDate datetime, 
	@Status int 

AS

UPDATE PriceItem SET
	   [PriceItemName] = @PriceItemName
	   ,[ScheduleId] = @ScheduleId
	   ,[PriceId] = @PriceId
	   ,[Quantity] = @Quantity
	   ,[TotalPrice] = @TotalPrice
	   ,[PriceItemType] = @PriceItemType
	   ,[CreatedBy] = @CreatedBy
	   ,[CreatedDate] = @CreatedDate
	   ,[UpdatedBy] = @UpdatedBy
	   ,[UpdatedDate] = @UpdatedDate
	   ,[Status] = @Status
WHERE [PriceItem].[PriceItemId] = @PriceItemId
GO

CREATE PROCEDURE PriceItemDelete
	@PriceItemId int
AS
DELETE FROM PriceItem
WHERE [PriceItem].[PriceItemId] = @PriceItemId
GO